#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e3+10;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<string,bool>map1,map2;
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
    LL q;cin>>q;
    while(q--){
        string s1,s2;
        cin>>(s1);LL n=s1.length();
        cin>>(s2);LL m=s2.length();
        bool flag=false;
        for(LL i=0;i<n;i++){
            map1.clear();map2.clear();
            string t1="";string t2="";
            for(LL j=0;j<i;j++) t1+=s1[j],map1[t1]=true;
            for(LL j=i-1;j>=0;j--) t2+=s2[j],map2[t2]=true;
            for(LL j=0;j<m;j++){

            }
        }
        if(flag){
            cout<<"YES"<<"\n";
        }
        else cout<<"NO"<<"\n";
    }
   	return 0;
}
